#ifndef HUICLOGIN_H
#define HUICLOGIN_H
#include <QtWidgets>
#include <QHash>
#include "../include/StdAfx.h"
#include "../include/HGlobalVariable.h"

class HLineEdit;
class HComboBox;
class HUICLogin : public QWidget
{
    Q_OBJECT
public:
    HUICLogin(QWidget *parent = NULL);
    ~HUICLogin();

    void                                setRememerCount(int nCount = 5);
	
    QString                             getUserName();
	void                                setUserName(QString strUserName);

    QString                             getPassword();
	void                                setPassword(QString strPassword);

	QString                             getWarning();
	void                                setWarning(QString strWarning);

protected:
    void                                paintEvent(QPaintEvent *event);
	void                                keyPressEvent(QKeyEvent *event);

private:
    void                                initControlSize();
    void                                initUI();
    bool                                readConfig();
    bool                                writeConfig();

private slots:
	void                                sltUserNameTextChanged(QString strText);
    void                                sltLineEditFocusStateChanged(bool bHasFocus);
    void                                sltComboBoxFocusStateChanged(bool bHasFocus);
	void                                sltComboBoxIndexChanged(QString strText);

    void                                sltLoginBtnClicked();
	void                                sltCloseBtnClicked();

private:
    QVBoxLayout                         *m_pvblMain;
    QVBoxLayout                         *m_pvblSubMain;
    QHBoxLayout                         *m_phblPanelControl;

    QPushButton                         *m_ppbMin;
    QPushButton                         *m_ppbClose;
    QPushButton                         *m_ppbSetting;

    QLabel                              *m_plblLogo;

    HComboBox                           *m_pcmbUser;
    QListView                           *m_lvUser;
    HLineEdit                           *m_plecmbUser;
    HLineEdit                           *m_plePassword;

    QCheckBox                           *m_pckbRPassword;

    QLabel                              *m_plblWarning;

    QPushButton                         *m_ppbLogin;

    QLabel                              *m_plblVersion;

    int                                 m_nCount;
    QString                             m_strVersion;

    int                                 m_nLoginBtnHeight;
    int                                 m_nLayoutSpacing;

    int                                 m_nMainLayoutL;
    int                                 m_nMainLayoutU;
    int                                 m_nMainLayoutR;
    int                                 m_nMainLayoutB;

    int                                 m_nSubMainLayoutL;
    int                                 m_nSubMainLayoutU;
    int                                 m_nSubMainLayoutR;
    int                                 m_nSubMainLayoutB;

	QHash<int,QPair<QString,QString>>   m_hashIndexToUserInfo;

signals:
    void                                sigSettingButtonClicked();
    void                                sigLoginBtnClicked();
    void                                sigMinBtnClicked();

};

#endif
